struct Node {
	int x;
	Node *next;
};

struct AdjList {
	Node *first;
	Node *last;
	int size;
};

void
init(struct AdjList *adjList)
{
	adjList->first = adjList->last = adjList->size = 0;
}

void
pushback(struct AdjList *al, int x)
{
	struct Node *new;

	new = malloc(sizeof(Node));
	new->x = x;
	new->next = NULL;
	if (!al->first)
		al->first = new;
	else
		al->last->next = new;
	al->last = new;
	al->size++;
}

void
free_lol(struct AdjList *al)
{
	struct Node *n, *p;
	p = n = al->first;
	while (n) {
		n = n->next;
		free(p);
		p = n;
	}
}

void
listprint(struct Node *node)
{
	while (node) {
		printf("%d%s", node->x, node->next ? " -> " : "\n");
		node = node->next;
	}
}
